from django.contrib import admin

from app_distribution_platform.models import *


class APPAdmin(admin.ModelAdmin):
    list_display = ('title', 'icon_link', 'click_num')
    search_fields = ('=title',)


class AppArticleAdmin(admin.ModelAdmin):
    list_display = ('title', 'add_time', 'app_id')
    search_fields = ('title', 'app_id')


class AppCategoryMappingAdmin(admin.ModelAdmin):
    list_display = ('app_id', 'category_id')
    search_fields = ('app_id', 'category_id')


class APPLibraryAdmin(admin.ModelAdmin):
    list_display = ('word', 'synonym_value')
    search_fields = ('=word',)


class APPNewsKeywordAdmin(admin.ModelAdmin):
    list_display = ('keyword', 'keyword_type', 'hot', 'current_num', 'max_num', 'status', 'add_time', 'grade', 'title')
    search_fields = ('=keyword', 'keyword_type', 'status', 'grade')


class APPNewsDetailRegularAdmin(admin.ModelAdmin):
    list_display = ('origin', 'origin_link', 'origin_type')
    search_fields = ('origin',)


class APPNewsListRegularAdmin(admin.ModelAdmin):
    list_display = ('search_engine', 'url', 'page')
    search_fields = ('search_engine',)


class ArticleAdmin(admin.ModelAdmin):
    list_display = ('title', 'site', 'add_time', 'keyword_id', 'click_num', 'hot')
    search_fields = ('site', 'title', '=keyword_id')


class AppCategoryAdmin(admin.ModelAdmin):
    list_display = ('id', 'category', 'shorthand')
    search_fields = ('id', 'shorthand')


class ArticleImageAdmin(admin.ModelAdmin):
    list_display = ('art_id', 'img_url', 'oss_img_url')
    search_fields = ('art_id',)


class SpiderNewsKeywordRelationAdmin(admin.ModelAdmin):
    list_display = ('keyword_id', 'p_id')
    search_fields = ('keyword_id', 'p_id')


class InternalChainAdmin(admin.ModelAdmin):
    list_display = ('word', 'link')
    search_fields = ('=word',)


class FriendlyLinkAdmin(admin.ModelAdmin):
    list_display = ('title', 'link')
    search_fields = ('=title',)


class LogsAdmin(admin.ModelAdmin):
    list_display = ('path', 'ip', 'user_agent', 'visit_time', 'referer', 'status_code')
    search_fields = ('path', 'ip', 'user_agent', 'referer', 'status_code')


class FileUploadAdmin(admin.ModelAdmin):
    list_display = ('username', 'filename', 'path')
    search_fields = ('=username', 'filename')


class RelatedParameterConfigAdmin(admin.ModelAdmin):
    list_display = ('host', 'index_app_count', 'detail_app_count')
    search_fields = ('host',)


admin.site.register(App, APPAdmin)
admin.site.register(AppArticle, AppArticleAdmin)
admin.site.register(AppCategory, AppCategoryAdmin)
admin.site.register(AppCategoryMapping, AppCategoryMappingAdmin)
admin.site.register(Article, ArticleAdmin)
admin.site.register(ArticleImage, ArticleImageAdmin)
admin.site.register(ArticleNew, ArticleAdmin)
admin.site.register(SpiderNewsDetailRegular, APPNewsDetailRegularAdmin)
admin.site.register(SpiderNewsKeyword, APPNewsKeywordAdmin)
admin.site.register(SpiderNewsKeywordRelation, SpiderNewsKeywordRelationAdmin)
admin.site.register(SpiderNewsListRegular, APPNewsListRegularAdmin)
admin.site.register(WordLibrary, APPLibraryAdmin)
admin.site.register(InternalChain, InternalChainAdmin)
admin.site.register(FriendlyLink, FriendlyLinkAdmin)
admin.site.register(Logs, LogsAdmin)
admin.site.register(FileUpload, FileUploadAdmin)
admin.site.register(RelatedParameterConfig, RelatedParameterConfigAdmin)
